package com.gaohe.web.controller.scp;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.scp.domain.CsCarParameter;
import com.gaohe.scp.service.ICsCarParameterService;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.common.core.page.TableDataInfo;

/**
 * 车辆参数照片Controller
 *
 * @author liuxiangyu
 * @date 2025-03-25
 */
@RestController
@RequestMapping("/scp/parameter")
public class CsCarParameterController extends BaseController
{

    @Autowired
    private ICsCarParameterService csCarParameterService;


    // 通过carId查询车辆参数照片详细------牛相善
//    @PreAuthorize("@ss.hasPermi('scp:parameter:query')")
    @GetMapping(value = "/car/{carId}")
    public AjaxResult getParameterByCarId(@PathVariable("carId") Long carId)
    {
        String parameter = csCarParameterService.selectCsCarParameterByCarId(carId).getParameter();

        return success(csCarParameterService.selectCsCarParameterByCarId(carId));
    }
    /**
     * 查询车辆参数照片列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:parameter:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsCarParameter csCarParameter)
    {
        startPage();
        List<CsCarParameter> list = csCarParameterService.selectCsCarParameterList(csCarParameter);
        return getDataTable(list);
    }

    /**
     * 导出车辆参数照片列表
     */
//    @PreAuthorize("@ss.hasPermi('scp:parameter:export')")
    @Log(title = "车辆参数照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsCarParameter csCarParameter)
    {
        List<CsCarParameter> list = csCarParameterService.selectCsCarParameterList(csCarParameter);
        ExcelUtil<CsCarParameter> util = new ExcelUtil<CsCarParameter>(CsCarParameter.class);
        util.exportExcel(response, list, "车辆参数照片数据");
    }

    /**
     * 获取车辆参数照片详细信息
     */
//    @PreAuthorize("@ss.hasPermi('scp:parameter:query')")
    @GetMapping(value = "/{parameterId}")
    public AjaxResult getInfo(@PathVariable("parameterId") Long parameterId)
    {
        return success(csCarParameterService.selectCsCarParameterByParameterId(parameterId));
    }

    /**
     * 新增车辆参数照片
     */
//    @PreAuthorize("@ss.hasPermi('scp:parameter:add')")
    @Log(title = "车辆参数照片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsCarParameter csCarParameter)
    {
        return toAjax(csCarParameterService.insertCsCarParameter(csCarParameter));
    }

    /**
     * 修改车辆参数照片
     */
//    @PreAuthorize("@ss.hasPermi('scp:parameter:edit')")
    @Log(title = "车辆参数照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsCarParameter csCarParameter)
    {
        return toAjax(csCarParameterService.updateCsCarParameter(csCarParameter));
    }

    /**
     * 删除车辆参数照片
     */
//    @PreAuthorize("@ss.hasPermi('scp:parameter:remove')")
    @Log(title = "车辆参数照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{parameterIds}")
    public AjaxResult remove(@PathVariable Long[] parameterIds)
    {
        return toAjax(csCarParameterService.deleteCsCarParameterByParameterIds(parameterIds));
    }
}
